package com.ayoka.parenting.adapter;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.MeditationQuestionBean;
import com.jincp.common.brvah.BaseQuickAdapter;
import com.jincp.common.brvah.BaseViewHolder;


/**
 * @ProjectName: ayoka7.
 * @ClassName: MeditationQuestionAdapter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/8/6 21:15.
 */

public class MeditationQuestionAdapter extends BaseQuickAdapter<MeditationQuestionBean, BaseViewHolder> {

    public MeditationQuestionAdapter() {
        super(R.layout.item_meditation_question);
    }

    @Override
    protected void convert(BaseViewHolder holder, MeditationQuestionBean item) {
        holder.setText(R.id.tv_question_title, item.Question)
                .setText(R.id.tv_answer, getAnswerText(item));
    }

    private String getAnswerText(MeditationQuestionBean item) {
        if (item.AnswerResult == null) return "";
        StringBuilder stringBuilder = new StringBuilder();
        for (MeditationQuestionBean.AnswerResultBean answerResultBean : item.AnswerResult) {
            if (stringBuilder.length() != 0) {
                stringBuilder.append(",");
            }
            stringBuilder.append(answerResultBean.Answer);
        }
        return stringBuilder.toString();
    }

}
